import { ref, Ref, WatchStopHandle } from "vue";

/**
 * 传感器
 */
export default class sensorData {
    private static instance: sensorData = new sensorData();
    /**
     * 传感器
     */
    public static get Default(): sensorData {
        return this.instance;
    }

    constructor() {
        window.addEventListener('unload', this.Dispose.bind(this));
    }

    Dispose() {
        window.removeEventListener('unload', this.Dispose);

        for (const watchStopHandle of this.watchStopHandles) {
            watchStopHandle();
        }
        this.watchStopHandles.clear();
    }
    public lat: Ref<string> = ref('');
    public lon: Ref<string> = ref('');
    public imageData: Ref<string> = ref('');

    private watchStopHandles: Array<WatchStopHandle> = [];

    public async Awake(): Promise<void> {
    }

    public async Destroy(): Promise<void> {
    }
}